/** 
 * This library is free software; you can redistribute it and/or modify it under 
 * the terms of the GNU Lesser General Public License as published by the Free 
 * Software Foundation; either version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License 
 * along with this library; if not, write to the Free Software Foundation, 
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */
package de.stoneageracer.crafting;

import de.stoneageracer.vehicles.VehiclePart;

/**
 * This class stores all Recipes and is used to actually "craft" the parts
 * @author Philipp
 */
public class Craft {
    
    private Recipe[] recipes = new Recipe[]{
        new Recipe(new BasePart("Wood Base"), 3, 0, 0),    // base part for 3 wood
        new Recipe(new BasePart("Stone Base"), 0, 3, 0),    // base part for 3 stone
        new Recipe(new BasePart("Bone Base"), 0, 0, 3)     // base part for 3 bone
    };
    
    /**
     * Used to craft a VehiclePart
     * @param wood number of wood used
     * @param stone number of stone used
     * @param bone number of bones used
     * @return the VehiclePart if a recipe for it exists (null otherwhise)
     */
    public VehiclePart craftPart(int wood, int stone, int bone){
        for(int i = 0; i < recipes.length; i++){
            if(recipes[i].check(wood, stone, bone)){
                System.out.println("crafted " + recipes[i].part);
                return recipes[i].part;
            }
        }
        return null;
    }
    
}
